import { ApiProperty } from '@nestjs/swagger';
import {
  IsEnum,
  IsNotEmpty,
  IsNumber,
  IsOptional,
  IsString,
} from 'class-validator';
import { ClassAttribute } from '../../entities/dbField';

export class UpdateCourseDto {
  @ApiProperty({ example: '计算机网络原理', description: '课程名字' })
  @IsString()
  @IsNotEmpty({ groups: ['update'], message: '课程名字必须填写' })
  name: string;

  @ApiProperty({ example: 2, description: '学分' })
  @IsNotEmpty({ groups: ['update'], message: '学分必须填写' })
  @IsNumber()
  credit: number;

  @ApiProperty({ example: 2, description: '老师表id' })
  @IsNotEmpty({ groups: ['update'], message: '必须填写' })
  @IsNumber()
  teacher_id: number;

  @ApiProperty({ example: 2, description: '专业表id' })
  @IsNotEmpty({ groups: ['update'], message: '必须填写' })
  @IsNumber()
  major_id: number;

  @ApiProperty({ example: '课程描述', description: '课程描述' })
  @IsOptional()
  desc?: string;

  @ApiProperty({ example: 'PUBLIC,MAJOR', description: '课程属性' })
  @IsNotEmpty({ groups: ['update'], message: '学分必须填写' })
  @IsEnum(ClassAttribute)
  attribute: ClassAttribute;
}
